# -*- coding: utf-8 -*-
# $Id: batchicon.py 24 2009-02-15 03:02:57Z gkuznets $

# mpcheckup
# Copyright 2008, 2009 Grigoriy Kuznetsov (gkuznets@yandex.ru)
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

from PyQt4.QtCore import Qt
from PyQt4.QtGui import QColor, QIcon, QPixmap, QPainter
from colors import *

def renderBatchIcon(batch):
    pix = QPixmap(64, 64)
    painter = QPainter(pix)
    painter.setBrush(non_checked_color)
    painter.drawRect(0, 0, 64, 64)
    # рисуем проверенные по первому разу задачи
    painter.setBrush(checked_once_color)
    for i in range(6):
        if i in batch.checkedProblems(0):
            painter.drawRect((i % 3)*64/3, (i/3)*32, 64/3, 32)
    
    # рисуем проверенные по второму разу задачи
    painter.setBrush(checked_twice_color)
    for i in range(6):
        if i in batch.checkedProblems(1):
            painter.drawRect((i % 3)*64/3, (i/3)*32, 64/3, 32)
    #if batch.group:
    #    painter.setBrush(QColor(255, 255, 255, 200))
    #    painter.drawRect(0, 0, 64, 64)
    painter.end()
    
    return QIcon(pix)